package com.oa.business.acc.dto;


import com.oa.common.DomainDto;
import com.oa.framework.acc.account.domain.AccountPrincipal;
import com.oa.framework.acc.account.domain.UserAccount;
import com.oa.framework.org.department.domain.Department;
import com.oa.framework.org.domain.Duty;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class AccountDto implements DomainDto<UserAccount> {

    private Long accountId;

    private String accountName;

    private String accountCode;

    private String systemUsername;

    private Long departmentId;

    private Long dutyId;

    private Short securityStatus;


    @Override
    public UserAccount transform() {
        //base info
        UserAccount account = new UserAccount();
        account.setAccountId(accountId);
        account.setAccountName(accountName);
        account.setAccountCode(accountCode);
        account.setSystemUsername(systemUsername);
        account.setSecurityStatus(securityStatus);
        //principal info
        if(dutyId == null || departmentId == null){
            return account;
        }
        AccountPrincipal priority = new AccountPrincipal();
        Department department = new Department();
        department.setDepartmentId(departmentId);
        Duty duty = new Duty();
        duty.setDutyId(dutyId);

        priority.setDuty(duty);
        priority.setDepartment(department);

        account.setPriorityPrincipal(priority);

        return account;
    }
}
